package tspda

import glory.xxd.Utils
import tsCIM.ResultCode
import tsCIM.modelForInterface.Header
import tsCIM.modelForInterface.RequestModel
import tsCIM.modelForInterface.ResultModel
import tsCIM.modelForInterface.Return

class PDAGetInspectionInfoRequestController {

    def commentService
    def index() {
        def result = ResultModel.getResultModel()
        try {
            def USERNAME = params.USERNAME?:""
            def EQPID = params.EQPID?:""
            def CHECKTYPE = params.CHECKTYPE?:""

            def MACHINENAME = params.MACHINENAME?:""


            def body = [EQPID:EQPID,USERNAME:USERNAME,CHECKTYPE:CHECKTYPE]
            Header header = new Header(TRANSACTIONID:Utils.getUUID(),MESSAGENAME:"PDAGetInspectionInfoRequest",MACHINENAME:MACHINENAME)
            Return aReturn = new Return()
            RequestModel requestModel = new RequestModel(header: header,body: body,aReturn: aReturn)
//            result = commentService.getJsonByTopic2Queue(requestModel,"sendmqname","returnmqname",true,responseXml)
            result = commentService.getJsonByTopic2Queue(requestModel,"jms.topic.PDA.TO.CIM","jms.queue.CIM.PDA.Send",false,false)
        }catch (Exception e){
            result.put(ResultModel.ServerErrorFlag,true)
            result.put(ResultModel.Code,ResultCode.SERVER_INTERFACE_ERROR.code)
            result.put(ResultModel.Msg,ResultCode.SERVER_INTERFACE_ERROR.msg)
            result.put(ResultModel.Data,e.getMessage())
        }finally{
            render Utils.getFormatString(result)
        }
    }

    def responseXml = """
<MESSAGE>
<HEADER>
  <TRANSACTIONID>e231d805-6a89-40d2-834d-33e01fe41514</TRANSACTIONID>
  <MESSAGENAME>PDAGetInspectionInfoResponse</MESSAGENAME>
  <MACHINENAME>WM-2112</MACHINENAME>
  <WORKNO>1</WORKNO>
  <EVENTUSER>CIM</EVENTUSER>
  <EVENTTIME>2019-03-16 17:16:56.457</EVENTTIME>
</HEADER>
<BODY>
  <INPUTDATALIST>
    <INPUTDATAINFO>
      <INPUTNAME>firstName1</INPUTNAME>
      <INPUTCNNAME>首检项1</INPUTCNNAME>
      <ISNUMBER>false</ISNUMBER>
      <DATATYPE>Text</DATATYPE>
      <DATAVALUE></DATAVALUE>
    </INPUTDATAINFO>
    <INPUTDATAINFO>
      <INPUTNAME>firstName2</INPUTNAME>
      <INPUTCNNAME>首检项2</INPUTCNNAME>
      <ISNUMBER>false</ISNUMBER>
      <DATATYPE>Radio</DATATYPE>
      <DATAVALUE></DATAVALUE>
    </INPUTDATAINFO>
    <INPUTDATAINFO>
      <INPUTNAME>firstName3</INPUTNAME>
      <INPUTCNNAME>首检项3</INPUTCNNAME>
      <ISNUMBER>false</ISNUMBER>
      <DATATYPE>Radio</DATATYPE>
      <DATAVALUE></DATAVALUE>
    </INPUTDATAINFO>
    <INPUTDATAINFO>
      <INPUTNAME>firstName4</INPUTNAME>
      <INPUTCNNAME>首检项4</INPUTCNNAME>
      <ISNUMBER>false</ISNUMBER>
      <DATATYPE>Combo</DATATYPE>
      <DATADETAIL>显示数据1；显示数据2；显示数据3；</DATADETAIL>
      <DATAVALUE></DATAVALUE>
    </INPUTDATAINFO>
  </INPUTDATALIST>
  <EQPID>DB-447</EQPID>
  <USERNAME>IE05</USERNAME>
  <CHECKTYPE>FirstCheck</CHECKTYPE>
  <FLOG>true</FLOG>
</BODY>
<RETURN>
  <RETURNCODE />
  <RETURNMESSAGE />
</RETURN>
</MESSAGE>
 """

}
